package utils

import "time"

func Timestamp() int64 {
	return time.Now().UnixNano() / 1e6
}

func FormatTime(timestamp int64) string {
	return time.Unix(timestamp/1000, 0).Format("2006-01-02 15:04:05")
}

func DayStartTime(day int) int64 {
	now := time.Now()
	year := now.Year()
	month := now.Month()
	day1 := now.Day()
	newTime := time.Date(year, month, day1+day, 0, 0, 0, 0, time.Local)
	return newTime.UnixNano() / 1e6
}

func FormatDuring(mss int64) string {
	days := mss / (1000 * 60 * 60 * 24)
	hours := (mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
	minutes := (mss % (1000 * 60 * 60)) / (1000 * 60)
	// seconds := (mss % (1000 * 60)) / 1000
	return JoinString("%v 天 %v 小时 %v 分钟 ", days, hours, minutes)
}
